fma
From cppreference.com
| Defined in header <math.h>
|
||
| float fmaf( float x, float y, float z ); |
(since C99) | |
| double fma( double x, double y, double z ); |
(since C99) | |
| long double fmal( long double x, long double y, long double z ); |
(since C99) | |
The fma functions compute (x*y) + z, rounded as one ternary operation, according to the rounding mode characterized by the value of FLT_ROUNDS.
Contents |
[edit] Parameters
| x, y, z | - | floating point values |
[edit] Return value
(x*y) + z, rounded as one ternary operation
[edit] Example
Run this code
#include <stdio.h> #include <math.h> int main() { #ifdef FP_FAST_FMAF printf("FP_FAST_FMAF defined\n"); #else printf("FP_FAST_FMAF undefined\n"); #endif #ifdef FP_FAST_FMA printf("FP_FAST_FMA defined\n"); #else printf("FP_FAST_FMA undefined\n"); #endif #ifdef FP_FAST_FMAL printf("FP_FAST_FMAL defined\n"); #else printf("FP_FAST_FMAL undefined\n"); #endif /* Expect the software version to be slower. */ printf("fma(2.0,3.0,1.0) = %f\n", fma(2.0,3.0,1.0)); return 0; }
Possible output:
FP_FAST_FMAF undefined FP_FAST_FMA undefined FP_FAST_FMAL undefined fmaf(2.0,3.0,1.0) = 7.000000
[edit] See also
| (C99) |
signed remainder of the division operation (function) |
| (C99) |
signed remainder as well as the three last bits of the division operation (function) |
| C++ documentation for fma
| |